package il.ac.tau.cvws.scrabblesidekick.tests;

import il.ac.tau.cvws.scrabblesidekick.server.engine.recoginition.TileImageMap;
import il.ac.tau.cvws.scrabblesidekick.server.engine.recoginition.calibration.stablecalibrate.CalibrationRecognizer;
import il.ac.tau.cvws.scrabblesidekick.server.engine.recoginition.tilelayout.TileLayoutRecognizer;
import il.ac.tau.cvws.scrabblesidekick.server.util.cv.CvUtil;
import il.ac.tau.cvws.scrabblesidekick.shared.datatype.game.Tile;
import il.ac.tau.cvws.scrabblesidekick.shared.datatype.game.TileLayout;

import com.googlecode.javacv.cpp.opencv_core.IplImage;

public class NivUnitTest
{
	public static void main(String[] args)
	{
		runCalibTest();
		runTileLayoutTest();
	}
	
	private static void runCalibTest()
	{
		IplImage sceneImage = CvUtil.loadImage("calib\\calib_2.jpg");
		
		CalibrationRecognizer calibRecognizer = new CalibrationRecognizer(800, 440);
		calibRecognizer.recognize(sceneImage);
	}
	
	private static void runTileLayoutTest()
	{
		IplImage sceneImage = CvUtil.loadImage("tile_layout\\half_tilt_3.jpg");
		
		TileImageMap tileImageMap = new TileImageMap();
		//Alphabet alphabet = new Alphabet();
		
		for (int i = 0; i < 22; i++)
		{
			Tile tile = new Tile(i, 0);
			IplImage tileImage = CvUtil.loadImage("niv_tests\\tile_" + i + ".png", true);
			
			tileImageMap.put(tile, tileImage);
			//alphabet.add(tile);
		}
		
		TileLayoutRecognizer recognizer = new TileLayoutRecognizer(tileImageMap, 800, 440);
		TileLayout layout = recognizer.recognize(sceneImage);
		
		System.out.println(layout);
	}
}
